<?php

class BadgeSystemController extends DrupalDefaultEntityController {
	public function save($badgeform) {
		$transaction = db_transaction();

		try {
			global $user;

			// Determine if we will be inserting a new badge progress
			$badgeform->is_new = empty( $badgeform->id );

			// Set the timestamp fields
			if ( empty( $badgeform->created ) ) {
				$badgeform->created = REQUEST_TIME;
			}
			$badgeform->updated = REQUEST_TIME;

			if ( $badgeform->is_new ) {
				// Save the new badge progress
				drupal_write_record('badgesystem', $badgeform);
				$op = 'insert';
			} else {
				// Save the updated badge progress
				drupal_write_record('badgesystem', $badgeform, 'id');
				$op = 'update';
			}

			// Clear internal properties
			unset($badgeform->is_new);

			// Ignore slave?!?
			db_ignore_slave();

			return $badgeform;
		} catch (Exception $e) {
			$transaction->rollback();
			watchdog_exception('badgesystem', $e, null, WATCHDOG_ERROR);

			return false;
		}
	}
}

function badgesystem_load($id = null, $uid = null, $bid = null) {
}